<div class="layui-card">
    <div class="layui-card-header">
        <h2 class="header-title">用户分布图</h2>
        <span class="layui-breadcrumb pull-right">
          <a href="#!home_console">首页</a>
          <a><cite>用户分布图</cite></a>
        </span>
    </div>
    <div class="layui-body" style="left:0px;height: 90%" id="map"  ></div>
</div>
<!-- js部分 -->

    
<script>
      layui.use(['form', 'table', 'util', 'config', 'admin'], function () {
			var $ = layui.jquery;
    var layer = layui.layer;
    var element = layui.element;
    var config = layui.config;
    var index = layui.index;
    var admin = layui.admin;
    var laytpl = layui.laytpl;

    
    
    layer.load(2);
    
    
 // 百度地图API功能
    var map = new BMap.Map("map", {
        enableMapClick: false
    });    // 创建Map实例
    map.centerAndZoom(new BMap.Point(105.403119, 38.028658), 5);  // 初始化地图,设置中心点坐标和地图级别
    map.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放

    map.setMapStyle({
        style: 'light'
    });


    var data = [];

    
    layer.load(2);
    $.ajax({
		url: config.base_server + 'api-log/nginxLog?access_token='+config.getToken().access_token ,
    	type : 'get',
    	async: false,//使用同步的方式,true为异步方式
    	data : { },//这里使用json对象
    	success : function(resp){
    		layer.closeAll('loading');
    		
    		
          if (resp.code == 0) {
      	        debugger ;
      	      
      	        $.each(resp.data,function(index,item){
      		
      	        	
      	        		
      	        		
      	        		if(typeof(item.nginx.access.geoip) !=undefined) {
      	      	        	
    	      	        	data.push(
    	      	        	    {
    	      	        	    	geometry: {
    	      	        	        type: 'Point',
    	                            coordinates: [item.nginx.access.geoip.location.lon ,item.nginx.access.geoip.location.lat]
    	      	        		},
    	      	        	    count: 10
    	      	        	});
          	        	}
      	        		
      	        	
      	        	
      		
      		
      	        }) ;
          }
    		
    		
    	},
    	fail:function(){
    	//code here...
    	}
    });
    
    layer.closeAll('loading');
    var dataSet = new mapv.DataSet(data);

    var options = {
        fillStyle: 'rgba(255, 50, 50, 0.6)',
        shadowColor: 'rgba(255, 50, 50, 1)',
        shadowBlur: 30,
        globalCompositeOperation: 'lighter',
        methods: {
            click: function (item) {
                console.log(item);
            }
        },
        size: 5,
        draw: 'simple'
    }

    var mapvLayer = new mapv.baiduMapLayer(map, dataSet, options);

    // dataSet.set(data); // 修改数据

    // mapvLayer.show(); // 显示图层
    // mapvLayer.hide(); // 删除图层
    
    
 
             
             
    });
</script>
                    